package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoTrainingTeacherType;
import com.muyu.danmo.service.IDanmoTrainingTeacherTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 教师培训类型Controller
 * 
 * @author ruoyi
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/danmoTrainingTeacherType")
public class DanmoTrainingTeacherTypeController extends BaseController
{
    @Autowired
    private IDanmoTrainingTeacherTypeService danmoTrainingTeacherTypeService;

    /**
     * 查询教师培训类型列表
     */
    @RequiresPermissions("system:danmoTrainingTeacherType:list")
    @GetMapping("/list")
    public Result list(DanmoTrainingTeacherType danmoTrainingTeacherType)
    {
        startPage();
        List<DanmoTrainingTeacherType> list = danmoTrainingTeacherTypeService.selectDanmoTrainingTeacherTypeList(danmoTrainingTeacherType);
        return getDataTable(list);
    }

    /**
     * 导出教师培训类型列表
     */
    @RequiresPermissions("system:danmoTrainingTeacherType:export")
    @Log(title = "教师培训类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoTrainingTeacherType danmoTrainingTeacherType)
    {
        List<DanmoTrainingTeacherType> list = danmoTrainingTeacherTypeService.selectDanmoTrainingTeacherTypeList(danmoTrainingTeacherType);
        ExcelUtil<DanmoTrainingTeacherType> util = new ExcelUtil<DanmoTrainingTeacherType>(DanmoTrainingTeacherType.class);
        util.exportExcel(response, list, "教师培训类型数据");
    }

    /**
     * 获取教师培训类型详细信息
     */
    @RequiresPermissions("system:danmoTrainingTeacherType:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoTrainingTeacherTypeService.selectDanmoTrainingTeacherTypeById(id));
    }

    /**
     * 新增教师培训类型
     */
    @RequiresPermissions("system:danmoTrainingTeacherType:add")
    @Log(title = "教师培训类型", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoTrainingTeacherType danmoTrainingTeacherType)
    {
        return toAjax(danmoTrainingTeacherTypeService.insertDanmoTrainingTeacherType(danmoTrainingTeacherType));
    }

    /**
     * 修改教师培训类型
     */
    @RequiresPermissions("system:danmoTrainingTeacherType:edit")
    @Log(title = "教师培训类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoTrainingTeacherType danmoTrainingTeacherType)
    {
        return toAjax(danmoTrainingTeacherTypeService.updateDanmoTrainingTeacherType(danmoTrainingTeacherType));
    }

    /**
     * 删除教师培训类型
     */
    @RequiresPermissions("system:danmoTrainingTeacherType:remove")
    @Log(title = "教师培训类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoTrainingTeacherTypeService.deleteDanmoTrainingTeacherTypeByIds(ids));
    }
}
